const express = require("express");
const loginRouter = require("./routers/login");
const userRouter = require("./routers/user");
const movieRouter = require("./routers/movie");
const uploadRouter = require("./routers/upload");
const assetsProxyRouter = require("./routers/assetsProxy");
const { verifyRouter } = require("../utils/jwt");

// 创建路由对象
const index = express.Router();

// 把其他各个细分路由绑定到这个总路由对象上
index.use("/login", loginRouter);
index.use("/users", verifyRouter, userRouter);
index.use("/movie", verifyRouter, movieRouter);
index.use("/base", verifyRouter, uploadRouter);
index.use("/base", verifyRouter, assetsProxyRouter);

index.use((req, res, next) => {
  res.status(404).send({
    code: 404,
    message: "接口不存在",
    data: null,
  });
});

module.exports = index;
